package com.yue.modbus.listener;

import com.yue.modbus.service.ReadService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
@Slf4j
public class AppListener implements ApplicationListener<ApplicationReadyEvent> {
    @Autowired
    //@Qualifier("modbusReadServiceImpl")
    @Qualifier("harmonyReadServiceImpl")
    private ReadService readService;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        log.info("app start init:" + LocalDateTime.now());
        readService.read();

    }
}
